package br.com.dlm.simuladoitil.activities;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import br.com.dlm.simuladoitil.R;
import br.com.dlm.simuladoitil.basicas.Categoria;
import br.com.dlm.simuladoitil.basicas.Questao;
import br.com.dlm.simuladoitil.fragments.ListaQuestoesFragment;

public class ListaQuestoesActivity extends Activity implements ListaQuestoesFragment.OnClickQuestaoListener {

    public static final String EXTRA_CATEGORIA = "PARAMETRO_CATEGORIA";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lista_questoes);

        Categoria categoria = (Categoria) getIntent().getSerializableExtra(EXTRA_CATEGORIA);

        ListaQuestoesFragment listaQuestoesFragment = ListaQuestoesFragment.newInstance(categoria);

        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.containerListaDeQuestoes, listaQuestoesFragment, "LISTA_QUESTOES");
        fragmentTransaction.commit();
    }

    @Override
    public void clickQuestao(Questao questao) {
        Intent intent = new Intent(this, QuestaoActivity.class);
        intent.putExtra(QuestaoActivity.EXTRA_QUESTAO, questao);
        startActivity(intent);
    }

    @Override
    public void clickQuestao(Questao questao, int numeroQuestao) {
        Intent intent = new Intent(this, QuestaoActivity.class);
        intent.putExtra(QuestaoActivity.EXTRA_QUESTAO, questao);
        intent.putExtra(QuestaoActivity.EXTRA_NUMERO_QUESTAO, numeroQuestao);
        startActivity(intent);
    }
}
